//TODO: java版临时注释 自动添加引用优先级低
//package com.inspur.edp.cef.generator.common;
//
//import Inspur.Ecp.Caf.Common.*;
//import Inspur.Ecp.Caf.ServiceMgr.*;
//import Inspur.Gsp.Lcm.CloudDev.FS.Api.*;
//import Inspur.Gsp.Lcm.Metadata.Api.*;
//
//public class ProjectRefHandler {
//  private FsService fsService = ServiceManager.<FsService>GetService();
//  private String relativePath;
//  private String projPath;
//  private XmlDocument projDoc;
//
//  public ProjectRefHandler(String relativePath) {
//    DataValidator.CheckForEmptyString(relativePath, "relativePath");
//
//    this.relativePath = relativePath;
//

//    var metadataProj =
//        ServiceManager.<IMetadataProjectService>GetService().GetMetadataProjInfo(relativePath);
//    this.projPath = Path.Combine(metadataProj.ProjectPath, metadataProj.ProjectFileName);
//    this.projDoc = LoadProjectDocument();
//  }
//
//  private XmlDocument loadProjectDocument() {
//    XmlDocument doc = new XmlDocument();
//    if (!fsService.ExistsAsFile(projPath)) {
//      throw new RuntimeException("元数据工程不存在");
//    }


//    //		using (var projStream = fsService.Read(projPath))
//    var projStream = fsService.Read(projPath);
//    try {
//      doc.Load(projStream);
//    } finally {
//      projStream.dispose();
//    }
//    return doc;
//  }
//
//  public final void save() {
//    MemoryStream stream = new MemoryStream();
//    projDoc.Save(stream);
//    stream.Seek(0, SeekOrigin.Begin);
//    fsService.Update(projPath, stream);
//  }
//
//  public final void addReference(String... assemblyPathList) {

//    for (var assemblyPath : assemblyPathList) {
//      AddReference(assemblyPath);
//    }
//  }
//
//  public final void addReference(String assemblyPath) {
//    DataValidator.CheckForEmptyString(assemblyPath, "assemblyPath");

//    var assemblyName = Path.GetFileNameWithoutExtension(assemblyPath);

//    var node =
//        projDoc.SelectSingleNode(
//            String.format("//ItemGroup/Reference[@Include='%1$s']", assemblyName));
//    if (node != null) {
//      if (node.FirstChild != null) {
//        node.RemoveChild(node.FirstChild);
//      }

//      var hintPath = projDoc.CreateElement("HintPath");
//      hintPath.InnerText = assemblyPath;
//      node.AppendChild(hintPath);
//    } else {

//      var hintPath = projDoc.CreateElement("HintPath");
//      hintPath.InnerText = assemblyPath;

//      var reference = projDoc.CreateElement("Reference");
//      reference.SetAttribute("Include", assemblyName);
//      reference.AppendChild(hintPath);

//      var itemGroup = projDoc.CreateElement("ItemGroup");
//      itemGroup.AppendChild(reference);
//      projDoc.DocumentElement.AppendChild(itemGroup);
//    }
//  }
//}
